<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/layout/common.xhtml">
	<ui:define name="body">
		<h:form id="form" acceptcharset="ISO-8859-1">
			<f:metadata>
				<f:event listener="#{associarBean.carregaObras()}" type="postAddToView" />
			</f:metadata>

			<p:remoteCommand name="udpateDialog" update="form" />

			<p:panel header="#{msg['massai.associacao.header']}">
				<h:panelGrid style="width: 100%;">
					<p:commandButton value="#{msg['massai.associacao.adicionarAssociacao']}" 
						action="associacaoCadastro" ajax="false" immediate="true" tabindex="1" />
				</h:panelGrid>
			
				<p:dataTable style="margin-top: 15px;" emptyMessage="#{msg['massai.comum.emptyMessage']}"
					value="#{associarBean.listaObras}" var="obra" sortMode="multiple" rows="10" paginator="true"
					paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
					currentPageReportTemplate="({currentPage} de {totalPages})" paginatorPosition="bottom" paginatorAlwaysVisible="false">

					<f:facet name="header"><h:outputText value="#{msg['massai.associacao.obraAssociada']}" /></f:facet>
	
					<p:column headerText="#{msg['massai.associacao.codigoColigada']}" sortBy="#{obra.codigoColigada}" width="80">
						<h:outputText value="#{genericUtilBean.completarZerosEsquerda(obra.codigoColigada, 6)}" />
					</p:column>
	
					<p:column headerText="#{msg['massai.associacao.codigoTotvs']}" sortBy="#{obra.codigoDepto}" width="120">
						<h:outputText value="#{obra.codigoDepto}" />
					</p:column>
					
					<p:column headerText="#{msg['massai.associacao.codigoSienge']}" sortBy="#{obra.codigoSienge}" width="90">
						<h:outputText value="#{obra.codigoSienge}" />
					</p:column>
					
					<p:column headerText="#{msg['massai.associacao.nomeObraTotvs']}" sortBy="#{obra.nome}">
						<h:outputText value="#{obra.nome}" />
					</p:column>
	
					<p:column headerText="#{msg['massai.associacao.nomeAssociacao']}" sortBy="#{obra.nomeFantasia}">
						<h:outputText value="#{obra.nomeFantasia}" />
					</p:column>
					
					<p:column headerText="#{msg['massai.associacao.status']}" sortBy="#{obra.status.descricao}" width="90">
						<h:outputText value="#{obra.status.descricao}" />
					</p:column>

					<p:column headerText="#{msg['massai.comum.editar']}" width="50" style="text-align: center;">
						<h:link outcome="associacaoCadastro?param=#{obra.id}" tabindex="2">
							<img src="#{facesContext.externalContext.requestContextPath}/imagens/ico_link.png" 
								width="16" height="16" border="0" name="#{msg['massai.comum.editar']}" 
								title="#{msg['massai.comum.editar']}" alt="#{msg['massai.comum.editar']}" />
						</h:link>
					</p:column>
				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>